import 'dart:convert';
import 'package:ichinesereader/models/book/book.dart';

List<Book> childrenHistoryResultFromJson(String str) =>
    List<Book>.from(json.decode(str).map((x) => Book.fromJson(x)));

String childrenHistoryResultToJson(List<Book> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

// class ChildrenHistoryResult {
//   ChildrenHistoryResult({
//     this.book,
//     this.folders,
//     this.inAudioPlaylist,
//     this.inFolder,
//     this.interestLevels,
//     this.lastReadAt,
//     this.maxScore,
//     this.programTypes,
//     this.quizAvailable,
//     this.quizCount,
//     this.readComplete,
//     this.readCount,
//     this.readProgress,
//     this.readStarted,
//   });

//   Book? book;
//   List<String>? folders;
//   bool? inAudioPlaylist;
//   bool? inFolder;
//   List<InterestLevel>? interestLevels;
//   int? lastReadAt;
//   MaxScore? maxScore;
//   List<ProgramType>? programTypes;
//   bool? quizAvailable;
//   int? quizCount;
//   bool? readComplete;
//   int? readCount;
//   int? readProgress;
//   bool? readStarted;

//   factory ChildrenHistoryResult.fromJson(Map<String, dynamic> json) =>
//       ChildrenHistoryResult(
//         book: Book.fromJson(json["book"]),
//         folders: json["folders"] != null
//             ? List<String>.from(json["folders"].map((x) => x))
//             : null,
//         inAudioPlaylist: json["inAudioPlaylist"],
//         inFolder: json["inFolder"],
//         interestLevels: json["interestLevels"] != null
//             ? List<InterestLevel>.from(
//                 json["interestLevels"].map((x) => InterestLevel.fromJson(x)))
//             : null,
//         lastReadAt: json["lastReadAt"],
//         maxScore: json["maxScore"] != null
//             ? MaxScore.fromJson(json["maxScore"])
//             : null,
//         programTypes: List<ProgramType>.from(
//             json["programTypes"].map((x) => ProgramType.fromJson(x))),
//         quizAvailable: json["quizAvailable"],
//         quizCount: json["quizCount"],
//         readComplete: json["readComplete"],
//         readCount: json["readCount"],
//         readProgress: json["readProgress"],
//         readStarted: json["readStarted"],
//       );

//   Map<String, dynamic> toJson() => {
//         "book": book != null ? book?.toJson() : null,
//         "folders":
//             folders != null ? List<dynamic>.from(folders!.map((x) => x)) : null,
//         "inAudioPlaylist": inAudioPlaylist,
//         "inFolder": inFolder,
//         "interestLevels": interestLevels != null
//             ? List<dynamic>.from(interestLevels!.map((x) => x.toJson()))
//             : null,
//         "lastReadAt": lastReadAt,
//         "maxScore": maxScore != null ? maxScore?.toJson() : null,
//         "programTypes": programTypes != null
//             ? List<dynamic>.from(programTypes!.map((x) => x.toJson()))
//             : null,
//         "quizAvailable": quizAvailable,
//         "quizCount": quizCount,
//         "readComplete": readComplete,
//         "readCount": readCount,
//         "readProgress": readProgress,
//         "readStarted": readStarted,
//       };
// }
